package shiyl.use.springboot.log4j2;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * 演示如何在Spring Boot工程中使用log4j2
 *
 * @author shiyl
 */
@SpringBootApplication
public class UseSpringbootLog4j2Application {

    private static Logger logger = LoggerFactory.getLogger(UseSpringbootLog4j2Application.class);

    public static void main(String[] args) {
        showLoggerInfo();
        useLog4j2();
        SpringApplication.run(UseSpringbootLog4j2Application.class, args);

    }

    static void useLog4j2() {

        logger.trace("输出 trace 日志");
        logger.debug("输出 debug 日志");
        logger.info("输出 info 日志");
        logger.warn("输出 warn 日志");
        logger.error("输出 error 日志");
    }

    static void showLoggerInfo() {
        logger.info("logger name : " + logger.getName());
        logger.error("logger name : " + logger.getName());
        logger.info("logger class name : " + logger.getClass().getName());
        logger.error("logger class name : " + logger.getClass().getName());
    }

}

